CREATE TABLE [dbo].[Users](
	[Id] uniqueidentifier NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[Password] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]



CREATE TABLE [dbo].[JobTitles](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](100)  NOT NULL,
 CONSTRAINT [PK_Name] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]



CREATE TABLE [dbo].[Candidats](
	[Id] [uniqueidentifier] NOT NULL,
	[FirstName] [nvarchar](50)  NOT NULL,
	[Surename] [nvarchar](50)  NOT NULL,
	[Title] [nvarchar](100)  NOT NULL,
 CONSTRAINT [PK_Candidats] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]




CREATE TABLE [dbo].[Resumes](
	[Id] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](100)  NOT NULL,
	[Content] [varbinary](max) NULL,
	[ContentType] [nvarchar](100)  NOT NULL,
	[Version] [int] NOT NULL,
 CONSTRAINT [PK_Resumes] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]



CREATE TABLE [dbo].[CandidateResumes](
	[Id] [uniqueidentifier] NOT NULL,
	[IdCandidate] [uniqueidentifier] NOT NULL,
	[IdResume] [uniqueidentifier] NOT NULL,
	[IdJobTitle] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_CandidateResumes] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]


ALTER TABLE [dbo].[CandidateResumes]  WITH CHECK ADD  CONSTRAINT [FK_CandidateResumes_Candidats] FOREIGN KEY([IdCandidate])
REFERENCES [dbo].[Candidats] ([Id])

ALTER TABLE [dbo].[CandidateResumes] CHECK CONSTRAINT [FK_CandidateResumes_Candidats]

ALTER TABLE [dbo].[CandidateResumes]  WITH CHECK ADD  CONSTRAINT [FK_CandidateResumes_JobTitles] FOREIGN KEY([IdJobTitle])
REFERENCES [dbo].[JobTitles] ([Id])

ALTER TABLE [dbo].[CandidateResumes] CHECK CONSTRAINT [FK_CandidateResumes_JobTitles]

ALTER TABLE [dbo].[CandidateResumes]  WITH CHECK ADD  CONSTRAINT [FK_CandidateResumes_Resumes] FOREIGN KEY([IdResume])
REFERENCES [dbo].[Resumes] ([Id])

ALTER TABLE [dbo].[CandidateResumes] CHECK CONSTRAINT [FK_CandidateResumes_Resumes]






